﻿Public MustInherit Class DrawingVisual
    Inherits Windows.Media.DrawingVisual

    Public Sub New()
        VisualXSnappingGuidelines = New DoubleCollection({20})
        VisualYSnappingGuidelines = New DoubleCollection({20})
    End Sub

    Protected MustOverride Overloads Property Drawing As System.Windows.Media.DrawingGroup
    'Public MustOverride ReadOnly Property Geometry As Geometry

    Public Property AutoRefresh As Boolean = False

    Public Property CanRefresh As Boolean = True

    Private _cleared As Boolean
    Public ReadOnly Property IsVisualCleared As Boolean
        Get
            Return _cleared
        End Get
    End Property

    Public Property DrawVisual As Boolean = True

    Public Overridable Sub RefreshVisual()
        'Log(ToString() & " redrawn at " & Now.ToLongTimeString)
        _cleared = False
        If DrawVisual Then
            Using dc As DrawingContext = RenderOpen()
                If CanRefresh Then dc.DrawDrawing(Drawing)
            End Using
        End If
    End Sub
    Public Overridable Sub ClearVisual()
        'Log(ToString() & " cleared at " & Now.ToLongTimeString)
        Using dc As DrawingContext = RenderOpen()
            If CanRefresh Then dc.DrawDrawing(Nothing)
        End Using
        _cleared = True
    End Sub
End Class
